﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:ChoWorkflowDashboard;assembly="
                    xmlns:dm="clr-namespace:ChoWorkflowServer.Model;assembly=ChoWorkflowServer.Model"
                    xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase">

    <!-- a data template for bound TaskGroupCategory instances -->
    <DataTemplate x:Key="TasksTemplate"
                DataType="{x:Type dm:ChoTaskGroupCategory}">
        <StackPanel x:Name="GroupPanel"
                Orientation="Horizontal"
                Margin="0,2,0,2">
            <Image x:Name="Folder"
             Source="/Images/FolderClosed.png" />
            <TextBlock x:Name="Name"
                 Margin="2,0,0,0"
                 Text="{Binding Path=Name}" />
        </StackPanel>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=IsTaskGroup}" Value="True">
                <Setter Property="Source" TargetName="Folder" Value="/Images/Folder.png" />
            </DataTrigger>
            
            <DataTrigger Binding="{Binding Path=IsTaskGroup}" Value="False">
                <Setter Property="Source" TargetName="Folder" Value="/Images/Task.png" />
            </DataTrigger>

            <!--<DataTrigger Binding="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
                   Value="True">
                <Setter Property="Source" TargetName="Folder" Value="/Images/FolderOpen.png" />
            </DataTrigger>-->

            <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource TemplatedParent}}"
                   Value="True">
                <!--<Setter Property="Foreground" TargetName="Name" Value="Red" />
                <Setter Property="Source" TargetName="Folder" Value="/Images/FolderSelected.png" />-->
                <Setter Property="BitmapEffect">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowColor="Black" />
                    </Setter.Value>
                </Setter>
            </DataTrigger>

            <!-- custom icons for the root nodes -->
            <DataTrigger Binding="{Binding Path=Header.Name, RelativeSource={RelativeSource TemplatedParent}}"
                   Value="All Tasks">
                <Setter Property="Source" TargetName="Folder" Value="/Images/Calendar.png" />
            </DataTrigger>

        </DataTemplate.Triggers>
    </DataTemplate>


    <!-- this is the style that is applied to the tree -->
    <Style x:Key="SimpleFolders"
         TargetType="{x:Type TreeViewItem}">
        <Style.Resources>
            <!-- override default brushes that show bad background colors -->
            <!--<Brush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</Brush>-->
            <!--<Brush x:Key="{x:Static SystemColors.ControlBrushKey}">Transparent</Brush>-->
            <Style TargetType="Border">
                <Setter Property="CornerRadius" Value="2"/>
            </Style>
        </Style.Resources>
        <Setter Property="HeaderTemplate"
            Value="{StaticResource TasksTemplate}" />
        <Setter Property="BorderThickness" Value="1.5"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="BorderBrush" Value="#adc6e5"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True"/>
                    <Condition Property="IsSelectionActive" Value="False"/>
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="LightGray"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <!-- 
    A default style for treeview controls. This one will automatically
    be applied as the custom tree's 'TreeStyle' property is not set.
  -->
    <Style x:Key="SimpleTreeStyle" TargetType="{x:Type TreeView}">
        <!--<Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0,1"
                             StartPoint="0,0">
                    <GradientStop Color="#FFF"
                        Offset="0.0" />
                    <GradientStop Color="#AAA"
                        Offset="1.0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>-->
        <Setter Property="BorderThickness"
            Value="1" />
        <Setter Property="BorderBrush"
            Value="#FFA6AAAB" />
    </Style>
    
    <!-- the context menu for the tree -->
    <ContextMenu x:Key="TasksMenu" >
        <MenuItem Command="Redo" IsEnabled="{Binding Path=IsAddTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Add Group" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Folder.png" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="New" IsEnabled="{Binding Path=IsAddTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Add Task" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Task.png" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Delete" IsEnabled="{Binding Path=IsRemoveTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Remove" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Remove.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Open" IsEnabled="{Binding Path=IsEditTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Edit" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Edit.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Copy" IsEnabled="{Binding Path=IsCopyTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Copy" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Copy.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Paste" IsEnabled="{Binding Path=IsCopyTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Paste" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Paste.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Replace" IsEnabled="{Binding Path=IsMoveTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Move" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Move.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="Save" IsEnabled="{Binding Path=IsExportTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Export" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Export.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Command="SaveAs" IsEnabled="{Binding Path=IsImportTaskEnabled}">
            <MenuItem.Header>
                <TextBlock Text="Import" VerticalAlignment="Center" />
            </MenuItem.Header>
            <MenuItem.Icon>
                <Border Padding="2">
                    <Image Source="/Images/Import.ico" Width="16" Height="16" />
                </Border>
            </MenuItem.Icon>
        </MenuItem>
    </ContextMenu>


    <!-- sorts categories by names in ascending order -->
    <!--<cm:SortDescriptionCollection x:Key="AscendingNames">
        <cm:SortDescription PropertyName="Header.Name"
                        Direction="Ascending" />
    </cm:SortDescriptionCollection>-->

    <!-- sorts categories by names in descending order -->
    <cm:SortDescriptionCollection x:Key="DescendingNames">
        <cm:SortDescription PropertyName="Header.Name"
                        Direction="Descending" />
    </cm:SortDescriptionCollection>



    <!-- default text style -->
    <Style TargetType="TextBlock">
        <Setter Property="TextWrapping"
            Value="Wrap" />
    </Style>


    <!-- the background of the main window -->
    <!--<LinearGradientBrush x:Key="WindowBrush"
                       EndPoint="0.5,1"
                       StartPoint="0.5,0">
        <GradientStop Color="#FFFAFAFA"
                  Offset="0.382" />
        <GradientStop Color="#FF405159"
                  Offset="0" />
        <GradientStop Color="#FF2D3539"
                  Offset="1" />
        <GradientStop Color="#FFDBDDDD"
                  Offset="0.592" />
        <GradientStop Color="#FFA6AAAB"
                  Offset="0.803" />
    </LinearGradientBrush>-->


    <!-- default style for hyperlinks -->
    <Style TargetType="{x:Type Hyperlink}">
        <Setter Property="Foreground"
            Value="#FFA72222" />
        <Setter Property="TextDecorations"
            Value="None" />
        <Setter Property="ToolTip"
            Value="Visit website" />
    </Style>

</ResourceDictionary>